package vn.edu.uit.hotelbooking.JsonParse;

import org.json.JSONObject;

import vn.edu.uit.hotelbooking.model.User;
import android.util.Log;

import com.google.gson.Gson;

public class UserParser {
    private static final String LOG_TAG= "UserParser";
    private static Gson gson = new Gson();
    
    /**
     * Get the user info from JSON object
     * @param jObject the JSON object contents userinfo
     * @return an User object
     */
    public static User getUserInfoFromJson(JSONObject jObject){
        User user = new User();
        try {
            user = gson.fromJson(jObject.toString(), User.class);
            return user;
        } catch (Exception e) {
            // TODO: handle exception
            Log.e(LOG_TAG, e.getMessage());
        }
        return null;
    }
}
